package com.oyjd.ybx.business.favorite.dao;

import java.util.List;

import org.hibernate.Query;
import org.springframework.stereotype.Component;

import com.oyjd.ybx.bean.po.GoodsInfo;
import com.oyjd.ybx.bean.po.ToFavorite;
import com.oyjd.ybx.business.favorite.ToFavoriteExVO;
import com.oyjd.ybx.fw.dao.BaseDao;

/**
 * 
 * 收藏用户数据处理层
 * 
 * @author <b>欧建东<br/>
 *         Email:oyjd@163.com</b>
 * @version 1.0
 */
@Component
public class FavoriteDao extends BaseDao {
	/**
	 * 获取收藏用户列表数据
	 * 
	 * @param page
	 *            页面对象
	 * @param account
	 *            帐号
	 * @return
	 */
	@SuppressWarnings("unchecked")
	public List<ToFavoriteExVO> getList(String account) {
		StringBuffer sb = new StringBuffer("select new " + ToFavoriteExVO.class.getName() + ToFavoriteExVO.STRUCT);
		sb.append(" from ").append(ToFavorite.class.getName()).append(" tofavorite,");
		sb.append(GoodsInfo.class.getName()).append(" g");
		sb.append(" where tofavorite.goodsId=g.goodsId and tofavorite.account=? order by tofavorite.createTime desc");

		// do result
		Query q = getSession().createQuery(sb.toString());
		q.setParameter(0, account);
		return q.list();
	}

}
